from django.contrib import admin
from student.models import *
from crm import models
from king_admin.service.stark import site, ModelStark


# Register your models here.


class BookConfig(ModelStark):
    list_display = ['name', 'price', 'publish', 'authors']
    search_fields = ['name', 'price']

    def patch_init(self, request, queryset):
        print('-------', queryset)
        queryset.update(price=20)

    patch_init.short_description = '批量初始化'

    actions = [patch_init]

    list_filter = ['publish', 'authors', 'name']


class UserConfig(ModelStark):
    list_display = ['id', 'name', 'year']
    list_display_links = ['name']
    # search_fields = ['name']


# class AuthorConfig(ModelStark):
#     list_display = ['name', 'sex']

site.register(BOOK, BookConfig)
site.register(UserInfo, UserConfig)
site.register(Publish)
site.register(Author)
